package org.neuedu.chapter09_0629.demo06;

import java.util.Arrays;

public class StringDemo04 {
    public static void main(String[] args) {
        // String[] split(String str) : 分割字符串
        String str1 = "黑桃^方块^草花^红心";
        String[] arr = str1.split("\\^");
        System.out.println(arr.length);
        System.out.println(Arrays.toString(arr));

        String str2 = "helloworld";
        // String substring(int begin) : 从指定索引处截取剩余字符串
        String str3 = str2.substring(2);
        System.out.println(str3);
        // String substring(int begin,int end) ： 从begin索引处截取到end前
        String str4 = str2.substring(2, 4);
        System.out.println(str4);

        // int length() : 返回字符串长度
        String str5 = "hello";
        System.out.println(str5.length());
    }
}
